package day2.homework;

import java.io.FileInputStream;
import java.io.IOException;

public
class Demo3 {
    public static
    void main(String[] args) {
        try (FileInputStream fis=new FileInputStream("D:\\IO\\testIO.txt");){
            int a=0,b=0,x;
            while ((x = fis.read()) != -1) {  // 使用while循环直到读取到文件末尾
                if (x == 65) {
                    a++;
                }else if (x == 97) {
                    b++;
                }
            }
            System.out.println("大写字母A的个数为：" + a);
            System.out.println("小写字母a的个数为：" + b);
            System.out.println("总个数为：" + (a + b));
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
